<template>
  <div class="tab-item" @click="changePath" :class="{ active: isActive }">
    <div class="icon"><slot name="top"></slot></div>
    <div><slot name="bottom"></slot></div>
  </div>
</template>

<script>
export default {
  name: 'TabItem',
  props: ['path'],
  methods: {
    changePath() {
      this.$router.replace(this.path)
    }
  },
  computed: {
    isActive() {
      return this.$route.path.includes(this.path)
    }
  }
}
</script>

<style lang="scss" scoped>
.tab-item {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  justify-content: center;
  font-size: 0.14rem;
  .icon {
    margin-bottom: 0.05rem;
    i {
      font-size: 0.2rem;
    }
  }
}
.active {
  color: orange;
}
</style>
